<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>BMI指数</title>
	</head>
	<body>
		<p>身高：</p>
		<input type="text" />
		<p>体重：</p>
		<input type="text" />
		<p>
			<input type="button" value="求BMI" onclick="bmi()" />
		</p>
		<div id="result"></div>
		<script>
			function bmi(){
				var height=document.getElementById('height');
				var weight=document.getElementById('weight');
				var result=document.getElementById('result');
				var h=height.value/100;
				var w=weight.value;
				var bmi=(w/h(h*h)).toFixed(2);
				var s="您的bmi值是："+bmi;
				if(bmi<18.5){
					s+="过轻";
				}else if(bmi<24){
					s+="正常";
				}else if(bmi<27){
					s+="肥胖";
				}else{
					s+="非常胖";
				}
				result.innerHTML=s;
			}
		</script>
	</body>
</html>
